#!/usr/bin/env python 
# -*- coding: utf-8 -*-
# @Time    : 2022/10/31 8:21
# @Author  : Junzhao
# @File    : numpy数组.py
# @Software: PyCharm
import numpy as np

print(np.__version__)  # numpy版本

arr1 = np.array([1, 2, 3, 4, 5, 6])
print(arr1)
print(type(arr1))  # <class 'numpy.ndarray'>

# print(dir(arr1))

# 一维
print("一维")
arr2 = np.array([1, 2, 3, 4, 5, 6], dtype=np.float32)
arr3 = np.array([1, 2, 3, 4, 5, 6], dtype=np.int32)

print(arr2)
print(arr3)

print(arr2.tolist())  # 不改变原来的numpy数组
print(arr2)
print(arr2.size)  # 大小
print(arr2.shape)  # 形状（矩阵）
# 2维
print("二维")
arr4 = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])
arr5 = np.array([[0, 1, 2], [3, 4, 5]])

print(arr4)
print(arr5)

print(arr4.shape)
print(arr5.shape)
print(arr4.size)
# 3维
print("三维")
arr6 = np.array([[[1, 1, 1], [1, 1, 1], [1, 1, 1]],
                 [[2, 2, 2], [2, 2, 2], [2, 2, 2]],
                 [[3, 3, 3], [3, 3, 3], [3, 3, 3]]])

print(arr6)
print(arr6.shape)
print(arr6.size)

# print(arr4.view(dtype=np.float32))

